﻿@model Nop.Web.Models.Blogs.BlogPostListModel
@using Nop.Web;
@using Nop.Web.Extensions;
@{
    Layout = "~/Views/Shared/_ColumnsTwo.cshtml";

    //title
    Html.AddTitleParts(T("PageTitle.Blog").Text);
}
@section left {
    @Html.Action("BlogMonths", "Blog")
    <div class="clear">
    </div>
    @Html.Action("BlogTags", "Blog")
    <div class="clear">
        </div>
    @Html.Action("FeatureProduct", "Catalog")
    <div class="clear">
    </div>
    @Html.Action("BestSelling", "Catalog")
        
}
<div class="blog">
    <div class="page-title">
        <table style="width: 100%;">
            <tr>
                <td class="title">
                    <h1>
                        @if (String.IsNullOrEmpty(Model.PagingFilteringContext.Tag))
                        {
                            if (Model.PagingFilteringContext.GetParsedMonth().HasValue)
                            {
                            @string.Format(T("Blog.FilteredByMonth").Text, Model.PagingFilteringContext.GetParsedMonth().Value.Year, Model.PagingFilteringContext.GetParsedMonth().Value.ToString("MMMM"));
                            }
                            else
                            {
                            @T("Blog")
                            }
                        }
                        else
                        {
                            @string.Format(T("Blog.TaggedWith").Text, Model.PagingFilteringContext.Tag);
                        }
                    </h1>
                </td>
                <td class="rss">
                    <a href="@Url.RouteUrl("BlogRSS", new { languageId = Model.WorkingLanguageId })">
                        <img title="@T("Blog.RSS.Hint")" src="@Url.Content("~/content/images/icon_rss.gif")" alt="@T("Blog.RSS")" /></a>
                </td>
            </tr>
        </table>
    </div>
    <div class="clear">
    </div>
    <div class="blogposts">
        @foreach (var item in Model.BlogPosts)
        {
            <div class="post">
                <a class="blogtitle" href="@Url.RouteUrl("BlogPost", new { blogPostId = item.Id, SeName = item.SeName })">
                    @item.Title</a><span class="blogdate">-
                        @item.CreatedOn.ToString("D")
                    </span>
                <div class="blogbody">
                    @Html.Raw(item.Body)
                </div>
                <div class="clear">
                </div>
                <div class="tags">
                    @if (item.Tags.Count > 0)
                    {
                        @T("Blog.Tags") 
                        <text>:&nbsp;</text>
                        for (int i = 0; i < item.Tags.Count; i++)
                        {
                            var tag = item.Tags[i];
                        <a href="@Url.RouteUrl("BlogByTag", new { tag = tag })">@tag</a>
                            if (i != item.Tags.Count - 1)
                            {
                        <text>,&nbsp;</text>
                            }
                        }
                    }
                </div>
                @if (item.AllowComments)
                {
                    <a href="@Url.RouteUrl("BlogPost", new { blogPostId = item.Id, SeName = item.SeName })" class="blogdetails">
                        @string.Format(@T("Blog.CommentsLink").Text, item.NumberOfComments)
                    </a>
                }
            </div>
        }
    </div>
    <div class="pager">
        @Html.Pager(Model.PagingFilteringContext).QueryParam("pagenumber")
    </div>
</div>
